{extend name="common/layout" /}
{block name="main"}
<div class="admin-main layui-anim layui-anim-upbit" ng-app="hd" ng-controller="ctrl">
    <div class="padding30">
         <h3 class="page-box-title">{$title}</h3>
         <blockquote class="layui-elem-quote layui-text" style="width:450px;">
            <h4 class="layui-note-title">{:lang('Note')}:</h4>
            <p class="layui-note-content">1.{:lang('For password recovery, please fill in carefully.')}</p>
            <p class="layui-note-content">2.{:lang('The password must be greater than 6 digits and less than 15 digits.')}</p>
    <!--       <a href="javascript:;" onClick="history.back()" class="layui-btn layui-btn-sm layui-btn-primary pull-rigth">{:lang('Back')}</a>
     -->      <div style="clear: both;"></div>
        </blockquote>
    </div>
     <div class="layui-form-box">
        
    <form class="layui-form ">
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('Nickname')}</label>
            <div class="layui-input-6">
                <input type="text" name="username" lay-verify="required" ng-model="field.username" value="" placeholder="{:lang('Please enter the login nickname')}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('User Group')}</label>
            <div class="layui-input-6"> 
                <select name="group_id" lay-verify="required" >
                    <option value="">{:lang('Please select a user group')}</option>
                    <?php foreach($authGroup as $group):?>
                        <option value="{$group['group_id']}" <?php if($group['group_id'] == $group_id){echo "selected";}?> >{$group['title']}</option>
                    <?php endforeach;?>
                </select>
            </div>
        </div>
        <?php if(is_array($users)):?>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('User Ownership')}</label>
            <div class="layui-input-6"> 
                <select name="sup_id">
                    <option value="0">{:lang('Please select the user account number')}</option>
                    <?php foreach($users as $user):?>
                        <option value="{$user['admin_id']}" <?php if($user['admin_id'] == $sup_id){echo "selected";}?> >{$user['email']}【{$user['title']}】</option>
                    <?php endforeach;?>
                </select>
            </div>
        </div>
    <?php else:?>
        <input type="hidden" name="sup_id" value="{$users}" >
    <?php endif;?>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('Email')}</label>
            <div class="layui-input-6">
                <input type="text" name="email" ng-model="field.email" lay-verify="email" placeholder="{:lang('Please enter the user mailbox')}" class="layui-input">
            </div>
           
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('Password')}</label>
            <div class="layui-input-6">
                <input type="password" name="pwd" placeholder="{:lang('Please enter the login password')}" {if condition="ACTION_NAME eq 'adminadd'"}lay-verify="required"{/if} class="layui-input">
            </div>
           
        </div>
        
        
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('Mobile')}</label>
            <div class="layui-input-6">
                <input type="text" name="mobile" ng-model="field.mobile" lay-verify="requiredt" data-field="mobile" value="" placeholder="{:lang('Please enter the cell phone number')}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('Telephone')}</label>
            <div class="layui-input-6">
                <input type="text" name="telephone" ng-model="field.telephone"  lay-verify="requiredt" data-field="telephone" value="" placeholder="{:lang('Please enter the cell phone number')}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('Company Name')}</label>
            <div class="layui-input-6">
                <input type="text" name="company" ng-model="field.company"  lay-verify="required" value="" placeholder="{:lang('Please enter the name of the company')}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('Company Address')}</label>
            <div class="layui-input-6">
                <input type="text" name="address" ng-model="field.address" lay-verify="required"  value="" placeholder="{:lang('Please enter the company address')}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('Position')}</label>
            <div class="layui-input-6">
                <input type="text" name="position" ng-model="field.position"  lay-verify="required" value="" placeholder="{:lang('Please enter your position')}" class="layui-input">
            </div>
        </div>
        </br></br>
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-label-no"></label>
            <div class="layui-input-6 pleft22">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('Submit')}</button>
            </div>
            
        </div>
       
    </form>
</div>
</div>
{/block}
{block name="footer"}
<script>
    var m = angular.module('hd',[]);
    m.controller('ctrl',['$scope',function($scope) {
        $scope.field = '{$info}'!='null'?{$info}:{group_id:'',username:'',email:'',mobile:'',position:'',address:'',company:'',sup_id:0};
        layui.use(['form', 'layer','upload'], function () {
            var form = layui.form, layer = layui.layer,$= layui.jquery,upload = layui.upload;
            
			form.render();
            form.on('submit(submit)', function (data) {
                loading =layer.load(1, {shade: [0.1,'#fff']});
                data.field.admin_id = $scope.field.admin_id;
                $.post("", data.field, function (res) {
                    layer.close(loading);
                    if (res.code > 0) {
                        layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                            location.href = res.url;
                        });
                    } else {
                        layer.msg(res.msg, {time: 1800, icon: 2});
                    }
                });
            });            
        });
    }]);
</script>
{/block}